//
//  RBDateFormatUtil.m
//  coyote
//
//  Created by Huadong Zheng on 2023/2/27.
//  Copyright © 2023 500wan. All rights reserved.
//

#import "RBFormatUtil.h"

@implementation RBFormatUtil

+(NSDate *) dateByDateFormat:(NSString *) dateFormat dateString:(NSString *) dateString{
    
    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
    
    dateFormatter.locale = [[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"];
    
    dateFormatter.dateFormat = dateFormat;
    return [dateFormatter dateFromString:dateString];
}

+(NSString *) dateStringByDateFormat:(NSString *) dateFormat date:(NSDate *) date{
    
    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.locale = [[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"];
    dateFormatter.dateFormat = dateFormat;
    
    
    return [dateFormatter stringFromDate:date];
}


+(NSString *) stringByNumber:(NSNumber*) num minDigits:(NSInteger) min maxDigits:(NSInteger) max{
    
//    NSNumb
    
    NSNumberFormatter * numberFormatter = [[NSNumberFormatter alloc] init];
    numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
    numberFormatter.minimumFractionDigits = min;
    numberFormatter.maximumFractionDigits = max;
    return [numberFormatter stringFromNumber:num];
}

@end
